#ifndef __HTTP_SERVER_H__
#define __HTTP_SERVER_H__

#include "libhv/HttpServer.h"
#include "album.h"
#include "common_info.h"
#include "system.h"
#include "rgb_power.h"
#include "cam_tele.h"

#include <tuple>

namespace dwarf {
    
class HttpServer {
public:
    HttpServer();
    ~HttpServer();

    int startServer();
    void setAlbumRouter();
    hv::Json getAlbumPictureJson(PictureInfo& picture_info);
    hv::Json getAlbumVideoJson(VideoInfo& video_info);
    hv::Json getAlbumBurstJson(BurstInfo& burst_info);
    hv::Json getAlbumPanoJson(PanoInfo& pano_info);
    hv::Json getAlbumAstroJson(AstroInfo& astro_info);
    hv::Json getAlbumAllJson(AlbumAllInfo& all_info);
    void setAlbumListRouter();

    void setCheckFileMd5Router();
    void setGetParamsConfigRouter();
    void setUploadFirmwareRouter();
    void setDownloadLogRouter();
    std::tuple<int, int, int> readVersionInfo(const std::string& file_path);
    void setGetFirmwareVersionRouter();
    int upgradeFirmware(std::string& firmware_path);
    void getDeviceInfoRouter();
    void setDeviceNameAndPsdRouter();
    void resetDeviceInfoRouter();
    void getResetStateRouter();

private:
    HttpService router;
    http_server_t server;

public:
    Album album_;
    System system_;
    RgbPower rgb_power_;
    CamTele cam_tele_;
};

}

#endif